import { isFunction, map, property } from 'lodash';


import './rewardTable.scss';

export default (props) => {
    const keys = map(props.columns, property('dataIndex'));

    return (
        <div className="customTableWrapper">
            <div className="tableHeader">
                {props.columns.map((col) => (
                    <span>{col.title}</span>
                ))}
            </div>
            <table className="tableContent">
                <tbody>
                    {props.dataSource.map((row) => {
                        return (
                            <tr key={row.key}>
                                {keys.map((k, index) => {
                                    const isRender = props.columns[index]['render'];
                                    return <td>{isFunction(isRender) ? isRender(row) : row[k]}</td>;
                                })}
                            </tr>
                        );
                    })}
                </tbody>
            </table>
        </div>
    );
};
